package com.nmgdz.bigdata.controller;

import com.nmgdz.bigdata.entity.User;

import com.nmgdz.bigdata.service.RedisService;
import com.nmgdz.bigdata.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired

    private UserService userService;

    @Autowired
    private RedisService redisService;

    @GetMapping("/gueryBuId")
    public User gueryById(int id) {
        return userService.gueryById(id);

    }
    /**
     * 增 改
     * @param user
     * @return
     */
    @PostMapping("/saveOrUpdate")
    public User saveOrUpdateUser(User user) {
        return userService.save(user);
    }

    /**
     * 删除用户
     * @param id
     * @return
     */
    @DeleteMapping("/delete")
    public Boolean deleteUser(int id) {
        userService.deleUserById(id);
        return true;
    }

}